using System;
using System.Collections.Generic;
using NetTopologySuite.Features;
using NetTopologySuite.Geometries;
using ProjNet.CoordinateSystems;
using SkiaSharp;
using ZMap.Layer;
using ZMap.Render;
using ZMap.Renderer;
using ZMap.Style;
using Point = NetTopologySuite.Geometries.Point;

namespace ZMap
{
    public interface IMap : IVisibility, IDisposable
    {
        /// <summary>
        /// Gets or sets the unique identifier of the map.
        /// </summary>
        Guid Id { get; set; }

        /// <summary>
        /// 地图渲染目标：SKCanvas，Graphics
        /// </summary>
        object Target { get; set; }

        /// <summary>
        /// 地图显示
        /// </summary>
        IView View { get; set; }
        
        IViewport Viewport { get; set; }

        /// <summary>
        /// Factory used to create geometries
        /// </summary>
        GeometryFactory GeometryFactory { get; set; }

        /// <summary>
        /// 可视区域
        /// </summary>
        Envelope Envelope { get; set; }

        /// <summary>
        /// 所有图层的最大有效区域
        /// </summary>
        Envelope EnvelopeOfLayers { get; set; }

        /// <summary>
        /// 图层列表，按图层添加顺序进行渲染，即先添加的先渲染
        /// </summary>
        IReadOnlyCollection<ILayer> Layers { get; set; }

        void AddLayer(ILayer layer);

        /// <summary>
        /// 背景颜色
        /// comment: 为了隔离不同的渲染实现，这里使用 RGB 的字符串来设置
        /// </summary>
        string BackgroundColor { get; set; }

        /// <summary>
        /// 地图的宽度
        /// </summary>
        int Width { get; set; }

        /// <summary>
        /// 地图的长度
        /// </summary>
        int Height { get; set; }

        /// <summary>
        /// 比例尺
        /// </summary>
        double Scale { get; }

        /// <summary>
        /// 遍历指定的图层，查找图斑
        /// todo: 参考 openlayers.PluggableMap.forEachFeatureAtPixel 里还有个参数 checkWrapped 是做什么的？
        /// </summary>
        /// <param name="pixel"></param>
        /// <param name="hitTolerance">点击容差</param>
        /// <param name="layerFilter"></param>
        /// <returns></returns>
        Feature GetFeaturesAtPixel(Coordinate pixel, int hitTolerance, Func<ILayer, bool> layerFilter);

        /// <summary>
        /// 像素点转换成坐标点
        /// </summary>
        /// <returns></returns>
        Coordinate GetCoordinateFromPixel(Coordinate pixel);

        /// <summary>
        /// 渲染器
        /// </summary>
        IMapRenderer Renderer { get; }

        void Render();
    }
}